package chances.webui.taglibs;

import java.util.Map;

import javax.servlet.jsp.JspException;

import chances.webui.model.Tab;

@SuppressWarnings("serial")
public class TabTag extends WebUITag {

	private Tab tab = new Tab();

	@Override
	protected void reset() {
		tab = new Tab();
		super.reset();
	}

	@Override
	protected void initContext(Map<String, Object> context) {
		context.put("tab", tab);
	}

	@Override
	public int doStartTag() throws JspException {
		TabPanelTag panelTag = (TabPanelTag) this.getParent();
		panelTag.addTab(this.tab);
		if(tab.isSelected()){
			panelTag.setSelectedTab(tab.getId());
		}
		return super.doStartTag();
	}

	public String getTitle() {
		return tab.getTitle();
	}

	public boolean isClose() {
		return tab.isClose();
	}

	public String getDataUrl() {
		return tab.getDataUrl();
	}

	public String getStyleClass() {
		return tab.getStyleClass();
	}

	public void setTitle(String title) {
		tab.setTitle(title);
	}

	public void setClose(boolean close) {
		tab.setClose(close);
	}

	public void setDataUrl(String dataUrl) {
		tab.setDataUrl(dataUrl);
	}

	@Override
	public String getId() {
		return tab.getId();
	}

	@Override
	public void setId(String id) {
		this.tab.setId(id);
	}
	@Override
	public void setStyleClass(String styleClass) {
		tab.setStyleClass(styleClass);
		super.setStyleClass(styleClass);
	}

	public boolean isSelected() {
		return tab.isSelected();
	}

	public void setSelected(boolean selected) {
		tab.setSelected(selected);
	
	}

}
